﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Globalization;

namespace ResxLocalizationEditor {
	
	class Resource {

		IDictionary<string, string> _stringMap;
        IDictionary<string, string> _commentMap;

		public Resource(CultureInfo language) {
			Language = language;

            _stringMap = new Dictionary<string, string>();
            _commentMap = new Dictionary<string, string>();
		}

        #region Properties

        public CultureInfo Language { get; private set; }

		public string OriginalResourcePath { get; set; }

        #endregion

        #region Language strings

        /// <summary>
        /// Returns a list of all keys.
        /// </summary>
        public IEnumerable<string> AllKeys {
			get {
				return _stringMap.Keys;
			}
		}

        /// <summary>
        /// Gets or sets the strings associated to keys.
        /// </summary>
        /// <param name="index">Key of the string resource.</param>
        /// <returns>Value of the key or null, if not set.</returns>
		public string this[string index] {
			get {
				if (_stringMap.ContainsKey(index))
					return _stringMap[index];
				else
					return null;
			}
			set {
				if (value != null)
					_stringMap[index] = value;
				else
					_stringMap.Remove(index);
			}
		}

        /// <summary>
        /// Gets or sets the comments associated to string keys.
        /// </summary>
        public IDictionary<string, string> Comments {
            get {
                return _commentMap;
            }
            set {
                if (value == null)
                    throw new ArgumentNullException();

                _commentMap = value;
            }
        }

        public IDictionary<string, string> ValueMap {
            get {
                return _stringMap;
            }
            set {
                if (value == null)
                    throw new ArgumentNullException();

                _stringMap = value;
            }
        }

        #endregion

    }

}
